package com.ddl.eurekaclient.dc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@RestController
public class DcController {

    @Autowired
    DiscoveryClient discoveryClient;

    @GetMapping("/dc")
    public String dc() {
        String services = "Services: " + discoveryClient.getServices();
        System.out.println(services);
        return services;
    }

    public static void main(String[] args) {

        long start = System.currentTimeMillis();
        List<User> userList = new ArrayList<User>();
        for(int i = 0; i< 1000000; i++) {
            userList.add(new User(11L, "aa", 1L));
        }
        System.out.println(userList.size());
        long end = System.currentTimeMillis();
        System.out.println(end - start);

    }
}
class User {

    public User() {
    }

    public User(Long id, String name, Long pId) {
        this.id = id;
        this.name = name;
        this.pId = pId;
    }

    private Long id;

    private String name;

    private Long pId;

    private List<User> childUserList;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getpId() {
        return pId;
    }

    public void setpId(Long pId) {
        this.pId = pId;
    }

    public List<User> getChildUserList() {
        return childUserList;
    }

    public void setChildUserList(List<User> childUserList) {
        this.childUserList = childUserList;
    }
}
